package br.com.winesys.geta.databinding.componentBinder;

import javax.swing.JPasswordField;
import br.com.winesys.geta.databinding.ComponentBinder;

public class JPasswordBinder implements ComponentBinder<JPasswordField> {

	private static final ComponentBinder<JPasswordField> INSTANCE = new JPasswordBinder();

	public static ComponentBinder<JPasswordField> getInstance() {
		return INSTANCE;
	}

	private JPasswordBinder() {
	}

	@Override
	public Object read(JPasswordField component) {
		return (component.getPassword().length > 0) ? new String(component.getPassword()) : "";
	}

	@Override
	public void write(JPasswordField component, Object value) {
		component.setText("");
	}
}
